package com.example.lifecycle;

import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

public class LifeCycleBean implements InitializingBean, DisposableBean {
    @Override
    public void destroy() throws Exception {
        System.out.println("spring DisposableBean cb");
    }

    @Override // 2
    public void afterPropertiesSet() throws Exception {
        System.out.println("spring InitializingBean cb");
    }

    @PostConstruct //1
    public void init() {
        System.out.println("JSR250 @PostConstruct cb");
    }

    @PreDestroy
    public void preDestroy() {
        System.out.println("JSR250 @preDestroy cb");
    }

    public void customInit() { // 3
        System.out.println("custom init method");
    }

    public void customDestroy() {
        System.out.println("custom destroy method");
    }
}
